from django.shortcuts import render
from rest_framework.generics import ListAPIView
from home.models import NavModel,BannerModel
from django0924.utils import constants
from home.serializers import NAVSerializer,BannerSerializer
from django0924.utils.views import CacheListAPIView
# Create your views here.
# class NavHeardListViews(ListAPIView):
#     queryset = NavModel.objects.filter(is_deleted=False,is_show=True,position=constants.NAV_HEARD).order_by('-id')[:constants.NAV_HEARD_SIZE]
#     serializer_class = NAVSerializer
#
#
#
# class NavFooterListViews(ListAPIView):
#     queryset = NavModel.objects.filter(is_deleted=False,is_show=True,position=constants.NAV_FOOTER).order_by('-id')[:constants.NAV_FOOTER_SIZE]
#     serializer_class = NAVSerializer
# class BannerListViews(ListAPIView):
#     queryset = BannerModel.objects.filter(is_deleted=False,is_show=True).order_by('-id')[:constants.BANNER_SIZE]
#     serializer_class = BannerSerializer


class NavHeardListViews(CacheListAPIView):
    queryset = NavModel.objects.filter(is_deleted=False,is_show=True,position=constants.NAV_HEARD).order_by('-id')[:constants.NAV_HEARD_SIZE]
    serializer_class = NAVSerializer



class NavFooterListViews(CacheListAPIView):
    queryset = NavModel.objects.filter(is_deleted=False,is_show=True,position=constants.NAV_FOOTER).order_by('-id')[:constants.NAV_FOOTER_SIZE]
    serializer_class = NAVSerializer
class BannerListViews(CacheListAPIView):
    queryset = BannerModel.objects.filter(is_deleted=False,is_show=True).order_by('-id')[:constants.BANNER_SIZE]
    serializer_class = BannerSerializer
